Merge pull request #1371 from thiagotalma/dry-tabs

Show Dry Run Result with tabs

Andrew Cantino %!s(int64=9) %!d(string=hace) años
padre
commit
d13edc2b53

+ 20 - 6
app/assets/javascripts/components/utils.js.coffee

@@ -99,18 +99,32 @@ class @Utils
99 99
         $('body').css(cursor: 'auto')
100 100
       .done (json) =>
101 101
         Utils.showDynamicModal """
102
-          <h5>Log</h5>
103
-          <pre class="agent-dry-run-log"></pre>
104
-          <h5>Events</h5>
105
-          <pre class="agent-dry-run-events"></pre>
106
-          <h5>Memory</h5>
107
-          <pre class="agent-dry-run-memory"></pre>
102
+          <!-- Nav tabs -->
103
+          <ul id="resultTabs" class="nav nav-tabs agent-dry-run-tabs" role="tablist">
104
+            <li role="presentation"><a href="#tabEvents" aria-controls="tabEvents" role="tab" data-toggle="tab">Events</a></li>
105
+            <li role="presentation"><a href="#tabLog" aria-controls="tabLog" role="tab" data-toggle="tab">Log</a></li>
106
+            <li role="presentation"><a href="#tabMemory" aria-controls="tabMemory" role="tab" data-toggle="tab">Memory</a></li>
107
+          </ul>
108
+          <!-- Tab panes -->
109
+          <div class="tab-content">
110
+            <div role="tabpanel" class="tab-pane" id="tabEvents">
111
+              <pre class="agent-dry-run-events"></pre>
112
+            </div>
113
+            <div role="tabpanel" class="tab-pane" id="tabLog">
114
+              <pre><small class="agent-dry-run-log"></small></pre>
115
+            </div>
116
+            <div role="tabpanel" class="tab-pane" id="tabMemory">
117
+              <pre class="agent-dry-run-memory"></pre>
118
+            </div>
119
+          </div>
108 120
           """,
109 121
           body: (body) ->
110 122
             $(body).
111 123
               find('.agent-dry-run-log').text(json.log).end().
112 124
               find('.agent-dry-run-events').text(json.events).end().
113 125
               find('.agent-dry-run-memory').text(json.memory)
126
+            active = if json.events.match(/^\[?\s*\]?$/) then 'tabLog' else 'tabEvents'
127
+            $('#resultTabs a[href="#' + active + '"]').tab('show')
114 128
           title: 'Dry Run Results',
115 129
           onHide: callback
116 130
       .fail (xhr, status, error) ->

+ 5 - 0
app/assets/stylesheets/application.css.scss.erb

@@ -94,6 +94,11 @@ span.not-applicable:after {
94 94
   content: "n/a";
95 95
 }
96 96
 
97
+// Dry Run Results Tabs
98
+.nav.agent-dry-run-tabs {
99
+  margin-bottom: 20px;
100
+}
101
+
97 102
 // Navbar
98 103
 .nav > li {
99 104
   &.job-indicator, &#event-indicator {